/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-09-23 15:21:55
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-23 17:16:53
 * @FilePath: \linePatrol\vue-element-plus-admin\src\views\SecurCheck\PlanMessage\CustomerUnitGroup\component\index.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { useI18n } from '@/hooks/web/useI18n'
import { useDictStore } from '@/store/modules/dictData'
import { ElTag } from 'element-plus'
import { reactive } from 'vue'
import { useDeptStore } from '@/store/modules/dept'
const { t } = useI18n()
const DictStore = useDictStore()
const DeptStore = useDeptStore()
//获取字典
DictStore.setDict('secur_user_type') //类型
DictStore.setDict('secur_user_state') //类型
DictStore.setDict('secur_gas_type') //类型
export const UniteCrudSchemas = reactive<CrudSchema[]>([
  {
    field: 'selection',
    type: 'selection',
    form: {
      hidden: true
    },
    detail: {
      hidden: true
    },
    search: {
      hidden: true
    },
    fixed: 'left'
  },
  {
    field: 'index',
    label: t('tableDemo.index'),
    type: 'index',
    detail: {
      hidden: true
    },
    search: {
      hidden: true
    }
  },
  {
    field: 'companyName',
    label: t('单位名称'),
    width: 100,
    search: {
      hidden: false,
      component: 'Input',
      componentProps: {
        placeholder: '单位名称'
      }
    }
  },
  {
    field: 'companyNo',
    label: t('单位编号'),
    width: 130,
    search: {
      hidden: false,
      component: 'Input',
      componentProps: {
        placeholder: '单位编号'
      }
    }
  },
  {
    field: 'userType',
    label: t('单位类型'),
    search: {
      hidden: true
    },
    formatter: (_: Recordable, __: any, cellValue: string) => {
      return DictStore.$state.secur_user_type?.map((item) => {
        if (item.dictValue == cellValue) {
          return item.dictLabel
        }
      })
    },
    detail: {
      slots: {
        default: (data: any) => {
          return DictStore.$state.secur_user_type?.map((item) => {
            if (item.dictValue == data.userType) {
              return <ElTag type={item.listClass}>{t(item.dictLabel)}</ElTag>
            }
          })
        }
      }
    }
  },

  {
    field: 'companyAddre',
    label: t('单位地址'),
    width: 200,
    search: {
      hidden: true
    }
  },
  {
    field: 'companyPhone',
    label: t('单位电话'),
    width: 100,
    search: {
      hidden: true
    }
  }
])
export const UserCrudSchemas = reactive<CrudSchema[]>([
  {
    field: 'selection',
    type: 'selection',
    form: {
      hidden: true
    },
    detail: {
      hidden: true
    },
    search: {
      hidden: true
    },
    fixed: 'left'
  },
  {
    field: 'index',
    label: t('tableDemo.index'),
    type: 'index',
    search: {
      hidden: true
    },
    detail: {
      hidden: true
    }
  },
  {
    field: 'userName',
    label: t('用户名'),
    width: 100,
    search: {
      hidden: false,
      component: 'Input',
      componentProps: {
        placeholder: '用户名称'
      }
    }
  },
  {
    field: 'userNumebr',
    label: t('用户编号'),
    width: 200,
    search: {
      hidden: false,
      component: 'Input',
      componentProps: {
        placeholder: '用户编号'
      }
    }
  },
  {
    field: 'userState',
    label: t('用户状态'),
    search: {
      hidden: true
    },
    formatter: (_: Recordable, __: any, cellValue: string) => {
      return DictStore.$state.secur_user_state?.map((item) => {
        if (item.dictValue == cellValue) {
          return item.dictLabel
        }
      })
    },
    detail: {
      slots: {
        default: (data: any) => {
          return DictStore.$state.secur_user_state?.map((item) => {
            if (item.dictValue == data.userState) {
              return <ElTag type={item.listClass}>{t(item.dictLabel)}</ElTag>
            }
          })
        }
      }
    }
  },
  {
    field: 'userType',
    label: t('用户性质'),
    search: {
      hidden: true
    },
    table: {
      hidden: true
    },
    detail: {
      slots: {
        default: (data: any) => {
          return DictStore.$state.secur_user_type?.map((item) => {
            if (item.dictValue == data.userType) {
              return <ElTag type={item.listClass}>{t(item.dictLabel)}</ElTag>
            }
          })
        }
      }
    }
  },
  {
    field: 'gogasAddre',
    label: t('用气地址'),
    width: 200,
    search: {
      hidden: true
    }
  },
  {
    field: 'deptId',
    label: t('所属公司'),
    width: 200,
    table: {
      hidden: true
    },
    search: { hidden: true },
    detail: {
      slots: {
        default: (data: any) => {
          return <span>{DeptStore.getDeptName(data.deptId)[0]?.deptName}</span>
        }
      }
    }
  },
  {
    field: 'floorNo',
    label: t('楼栋'),
    table: {
      hidden: true
    },
    search: {
      hidden: true
    }
  },
  {
    field: 'unitNo',
    label: t('单元'),
    table: {
      hidden: true
    },
    search: {
      hidden: true
    }
  },
  {
    field: 'roomNo',
    label: t('房间号'),
    search: { hidden: true },
    table: { hidden: true },
    form: {
      hidden: true
    }
  },
  {
    field: 'gasType',
    label: t('气源类型'),
    table: {
      hidden: true
    },
    width: 200,
    search: {
      hidden: true
    },
    detail: {
      slots: {
        default: (data: any) => {
          return DictStore.$state.secur_gas_type?.map((item) => {
            if (item.dictValue == data.gasType) {
              return <ElTag type={item.listClass}>{t(item.dictLabel)}</ElTag>
            }
          })
        }
      }
    }
  },
  {
    field: 'contacts',
    label: t('用气联系人'), //暂无
    width: 100,
    search: {
      hidden: true
    }
  },
  {
    field: 'contPhone',
    label: t('联系人联系方式'), //暂无
    width: 100,
    search: {
      hidden: true
    }
  }
])
